<?php
//ExceptionPage::getExceptionPage
class ExceptionPage {
	
	public static function getExceptionPage(Exception &$e, $advice = '') {
		return Templater::getOnlyPHP ( 'views/system/exception.php', (array ('msg' => $e->getMessage (), 'errTrace' => str_replace ( "\t", '&nbsp;&nbsp;', str_replace ( "\n", '<br/>', ErrorHandler::getBacktrace ( 2 ) ) ), 'trace' => self::print_array ( $e->getTrace () ), 'advice' => $advice, 'get' => self::print_array ( $_GET ), 'post' => self::print_array ( $_POST ), 'session' => self::print_array ( $_SESSION ) )) );
	}
	
	public static function getExceptionPageFromString($e, $advice = '') {
      return Templater::getOnlyPHP ( 'views/system/exception.php', (array ('msg' => $e, 'errTrace' => str_replace ( "\t", '&nbsp;&nbsp;', str_replace ( "\n", '<br/>', ErrorHandler::getBacktrace ( 2 ) ) ), 'trace' => '', 'advice' => $advice, 'get' => self::print_array ( $_GET ), 'post' => self::print_array ( $_POST ), 'session' => self::print_array ( $_SESSION ) )) );
   }
	
	public static function print_array($var) {
		ob_start ();
		echo '<pre>';
		print_r ( $var );
		echo '</pre>';
		$txt = ob_get_contents ();
		ob_end_clean ();
		chdir ( dirname ( $_SERVER ['SCRIPT_FILENAME'] ) );
		return $txt;
	}

}

?>